#ifndef RECEIVERWIDGET_H
#define RECEIVERWIDGET_H

#include <QWidget>
#include <QPainter>
#include <QTcpServer>
#include <QTcpSocket>
#include "videodecoder.h"
#include "audiodecoder.h"
#include "rtprecv.h"

namespace Ui {
class ReceiverWidget;
}

class ReceiverWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ReceiverWidget(QWidget *parent, const QString& devicename);
    ~ReceiverWidget();

    void init(); //初始化窗口、套接字、接收缓冲区等信息

public slots:
    void newConnection();
    void recvTcpData();

private slots:
    void on_pushButton_clicked();

private:
    Ui::ReceiverWidget *ui;

    // 提前协商音视频传输的信息，控制视频发送
    QTcpServer server;
    QTcpSocket *socket;

    RTPRecv rtpRecv;       //RTP包接受者线程
    VideoDecoder vDecoder; //视频解码线程
    AudioDecoder aDecoder; //音频解码线程

    QString name; //设备昵称
    QUdpSocket *udpSocket = nullptr; //用于广播设备信息
};

#endif // RECEIVERWIDGET_H
